package com.example.redismanual.dao.actionExamples.Hyperloglog;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class UniqueCounter {

    @Autowired
    StringRedisTemplate stringRedisTemplate;

    private String uniKey = "testUniKey";

    public void count_in(String itemKey){
        stringRedisTemplate.opsForHyperLogLog().add(uniKey,itemKey);
    }

    public int get_result(){
        return stringRedisTemplate.opsForHyperLogLog().size(uniKey).intValue();
    }
}
